package w2

import scala.::
import scala.collection.mutable._

object ListTest2 {
  def main(args: Array[String]): Unit = {
    val l = List("dog", "pig", "cow", "goat")
    val l2 = "cock" :: l
    println(l2)
    val l3 = "hen" +: l
    println(l3)
    //val l5 = List("monkey")
    val l4 = List("monkey") ::: l
    println(l4)

    println("前5：")
    println(l4.take(3))
    println("最后一个:")
    println(l4.tail)
    println(l4.head)
    println("下标3:")
    println(l4(3)) //update,apply

    val l5 = l ++ l4
    println("合并后：")
    println(l5)
    println(l5.size)
    val l9 = List("one", "two", "three")
    //val l6 = l5.:::(l9)
    val l6 = l5 ++: (l9)

    println("List6:")
    println(l6)
    for (x <- l5) println(x)
    //    val l = ListBuffer("dog", "pig", "cow", "goat")
    //    println(l)
    //    l += "hen"
    //    println(l)
    //    l =l.::"cock"
    //    println(l)

    //    l :+ "cock"
    //    println(l)
  }
}
